package com.netty.example.nio;

import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

public class NIOTest9 {
    public static void main(String[] args) throws Exception {
        RandomAccessFile randomAccessFile = new RandomAccessFile("NIOTest9.txt", "rw");
        FileChannel channel = randomAccessFile.getChannel();
        FileLock lock = channel.lock();
        System.out.println("valid: " + lock.isValid());
        System.out.println("lock type: " + lock.isShared());
        lock.release();
        channel.close();
        randomAccessFile.close();

    }
}
